home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume22 / pty / part01 next >
Encoding:
Internet Message Format  |  1990-10-09  |  54.2 KB

  1. Subject:  v23i031:  Run a program under a pty session, Part01/06
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: c8bfce4a 3a9f2967 7f682eaf c4c836ba
  5.  
  6. Submitted-by: Dan Bernstein <brnstnd@kramden.acf.nyu.edu>
  7. Posting-number: Volume 23, Issue 31
  8. Archive-name: pty/part01
  9.  
  10. [  This is the Ginsu knife (it slices, it dices, it never rusts) that
  11.    Dan has been talking about in comp.unix.wixards/internals for some
  12.    time now.  It is a mind-blower.  --r$  ]
  13.  
  14. pty - run a program under a pty session
  15.  
  16. pty is meant as the sole interface between pseudo-terminals and the rest
  17. of the system. Some features: improved security; over fifty options for
  18. precise control; session disconnecting and reconnecting; full efficiency
  19. after a reconnect; a gradual upgrade path so that all your old utilities
  20. will work without change; support for applications that need full pty
  21. control; and a reasonably smart install script. Also in this package are
  22. twenty-one utilities, including a ``script'' that actually works.
  23.  
  24. pty has been thoroughly tested on several BSD 4.3-based machines and
  25. tested on several BSD 4.2-based machines. It should be easy to port to
  26. any system supporting pseudo-terminals and UNIX-domain sockets. If you
  27. know any application of ptys that this program can't handle, or if you
  28. have a different machine that would benefit from the modularity and
  29. power of a pty port, please let the author know.
  30.  
  31.  
  32. pty does not work under POSIX-based machines (such as SunOS 4.1), even
  33. when it works perfectly under their predecessors (such as SunOS 4.0.3).
  34. The main problem is POSIX's introduction of sessions and the way it
  35. kills a non-orphaned process in an orphaned process group. There are
  36. other incompatibilities, mostly minor but some (like accounting and
  37. setuid problems) important. The author is working on a POSIX port.
  38.  
  39. #! /bin/sh
  40. # This is a shell archive.  Remove anything before this line, then feed it
  41. # into a shell via "sh file" or similar.  To overwrite existing files,
  42. # type "sh file -c".
  43. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  44. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  45. # Contents:  PACKNOTES README MANIFEST FILES INSTALL patch
  46. #   patch/telnetd.90.06.28.patch util
  47. # Wrapped by rsalz@litchi.bbn.com on Wed Oct 10 10:11:35 1990
  48. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  49. echo If this archive is complete, you will see the following message:
  50. echo '          "shar: End of archive 1 (of 6)."'
  51. if test -f 'PACKNOTES' -a "${1}" != "-c" ; then 
  52.   echo shar: Will not clobber existing file \"'PACKNOTES'\"
  53. else
  54.   echo shar: Extracting \"'PACKNOTES'\" \(1756 characters\)
  55.   sed "s/^X//" >'PACKNOTES' <<'END_OF_FILE'
  56. XBad character 010 in line 384 of "INSTALL".
  57. XBad character 010 in line 385 of "INSTALL".
  58. XBad character 010 in line 401 of "INSTALL".
  59. XBad character 010 in line 402 of "INSTALL".
  60. XBad character 010 in line 428 of "INSTALL".
  61. XBad character 010 in line 429 of "INSTALL".
  62. XBad character 010 in line 443 of "INSTALL".
  63. XBad character 010 in line 444 of "INSTALL".
  64. XBad character 010 in line 467 of "INSTALL".
  65. XBad character 010 in line 468 of "INSTALL".
  66. XFound 10 control chars in "INSTALL"
  67. X
  68. XBad character 07 in line 98 of "util/write.c".
  69. XFound 1 control char in "util/write.c"
  70. X
  71. XBad character 07 in line 30 of "util/lock.c".
  72. XBad character 07 in line 30 of "util/lock.c".
  73. XBad character 07 in line 30 of "util/lock.c".
  74. XBad character 07 in line 30 of "util/lock.c".
  75. XBad character 07 in line 30 of "util/lock.c".
  76. XBad character 07 in line 30 of "util/lock.c".
  77. XBad character 07 in line 30 of "util/lock.c".
  78. XBad character 07 in line 30 of "util/lock.c".
  79. XBad character 07 in line 30 of "util/lock.c".
  80. XBad character 07 in line 30 of "util/lock.c".
  81. XBad character 07 in line 30 of "util/lock.c".
  82. XBad character 07 in line 30 of "util/lock.c".
  83. XBad character 07 in line 30 of "util/lock.c".
  84. XBad character 07 in line 30 of "util/lock.c".
  85. XBad character 07 in line 30 of "util/lock.c".
  86. XBad character 07 in line 30 of "util/lock.c".
  87. XBad character 07 in line 30 of "util/lock.c".
  88. XBad character 07 in line 34 of "util/lock.c".
  89. XBad character 07 in line 36 of "util/lock.c".
  90. XBad character 07 in line 38 of "util/lock.c".
  91. XFound 20 control chars in "util/lock.c"
  92. X
  93. XBad character 07 in line 53 of "util/wall.c".
  94. XFound 1 control char in "util/wall.c"
  95. X
  96. XBad character 010 in line 2 of "util/script.tidy".
  97. XBad character 010 in line 2 of "util/script.tidy".
  98. XFound 2 control chars in "util/script.tidy"
  99. END_OF_FILE
  100.   if test 1756 -ne `wc -c <'PACKNOTES'`; then
  101.     echo shar: \"'PACKNOTES'\" unpacked with wrong size!
  102.   fi
  103.   # end of 'PACKNOTES'
  104. fi
  105. if test -f 'README' -a "${1}" != "-c" ; then 
  106.   echo shar: Will not clobber existing file \"'README'\"
  107. else
  108.   echo shar: Extracting \"'README'\" \(3922 characters\)
  109.   sed "s/^X//" >'README' <<'END_OF_FILE'
  110. Xpty - run a program under a pty session
  111. X
  112. Xpty is meant as the sole interface between pseudo-terminals and the rest
  113. Xof the system. Some features: improved security; over fifty options for
  114. Xprecise control; session disconnecting and reconnecting; full efficiency
  115. Xafter a reconnect; a gradual upgrade path so that all your old utilities
  116. Xwill work without change; support for applications that need full pty
  117. Xcontrol; and a reasonably smart install script. Also in this package are
  118. Xtwenty-one utilities, including a ``script'' that actually works.
  119. X
  120. Xpty has been thoroughly tested on several BSD 4.3-based machines and
  121. Xtested on several BSD 4.2-based machines. It should be easy to port to
  122. Xany system supporting pseudo-terminals and UNIX-domain sockets. If you
  123. Xknow any application of ptys that this program can't handle, or if you
  124. Xhave a different machine that would benefit from the modularity and
  125. Xpower of a pty port, please let the author know.
  126. X
  127. X
  128. Xpty does not work under POSIX-based machines (such as SunOS 4.1), even
  129. Xwhen it works perfectly under their predecessors (such as SunOS 4.0.3).
  130. XThe main problem is POSIX's introduction of sessions and the way it
  131. Xkills a non-orphaned process in an orphaned process group. There are
  132. Xother incompatibilities, mostly minor but some (like accounting and
  133. Xsetuid problems) important. The author is working on a POSIX port.
  134. X
  135. X
  136. Xpty version 3.001, August 21, 1990.
  137. XCopyright (c) 1990, Daniel J. Bernstein.
  138. XAll rights reserved.
  139. X
  140. XThis distribution packaged August 22, 1990.
  141. X
  142. XGeneral layout:
  143. XCHANGES         Description of changes since first distributed version
  144. XCOPYRIGHT       A comprehensible copyright notice
  145. XFILES           File list (used by make shar)
  146. XINSTALL         A script to guide you through compilation and installation
  147. XINSTALLREADABLE INSTALL's information, in a format you can reasonably edit
  148. XMANIFEST        Shipping list
  149. XQUESTIONS       Some questions that pty answers
  150. XREADME          This document
  151. XTESTS           A script to guide you through some tests
  152. XMakefile        Installation commands
  153. X*.c             Programs
  154. X*.h             Header files
  155. Xpty.man         Documentation
  156. Xpatch/*         Patches to other programs to better use pty
  157. Xutil/*          Utilities
  158. X
  159. XBefore you do anything else, run the INSTALL script. It'll guide you
  160. Xthrough compiling and installing pty and the utilities. Then run TESTS
  161. Xto exercise a few of pty's features on your system. patch/ is separate;
  162. Xread patch/README at your leisure.
  163. X
  164. XRead CHANGES for a list of changes. pty -C and pty -W give copyright and
  165. Xwarranty information; pty -H prints a help screen.
  166. X
  167. XNote that INSTALL, util/lock.c, util/script.tidy, util/write.c, and
  168. Xutil/wall.c all contain control characters.
  169. X
  170. X
  171. XKnown problems:
  172. X
  173. XPOSIX compatibility---might as well do complete rewrite
  174. Xlast was removed but is mentioned in INSTALL and INSTALLREADABLE
  175. XINSTALL's usleep test is not accurate in Ultrix 3.1C (aargh)
  176. Xchildsig = SIGCONT for TSTP in master.c?
  177. XPIPE should be handled by finish in sigler.c for NO_FDPASSING folks
  178. Xsesslist gives error for a session directory not yet created
  179. Xpty -H lists /etc/wtmp---guaranteed to confuse some people
  180. XQUESTIONS and TESTS list sed ... | more, race; more should be grep x
  181. Xon cannot chdir to session directory, pty does not restore correctly
  182. X  (set up your session directory correctly!)
  183. X
  184. X
  185. XTODO list:
  186. X
  187. XINSTALLSU script, for the final stages of installation
  188. Xfix PTYDIR propagation into utilities
  189. Xvhangup()? this is a sticky issue. probably not but we'll see
  190. Xlocking on /etc/utmp and /usr/adm/wtmp? not necessary if APPEND works
  191. Xgenerally handle signals better in sigler
  192. Xclean up ``last'' and include it in package
  193. X``detach''? not yet, for reasons discussed in paper
  194. Xmust pty really stop on pty -T ... &?
  195. X``utmpinit'', so that pty and login will get along---generally useful
  196. X
  197. X
  198. XMore comprehensive discussion will be available soon in ``The Design,
  199. XImplementation, and Use of a Pseudo-Terminal Manager.''
  200. END_OF_FILE
  201.   if test 3922 -ne `wc -c <'README'`; then
  202.     echo shar: \"'README'\" unpacked with wrong size!
  203.   fi
  204.   # end of 'README'
  205. fi
  206. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  207.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  208. else
  209.   echo shar: Extracting \"'MANIFEST'\" \(2906 characters\)
  210.   sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  211. X   File Name        Archive #    Description
  212. X----------------------------------------------------------
  213. XPACKNOTES                  1    
  214. XREADME                     1    
  215. XMANIFEST                   1    This shipping list
  216. XCHANGES                    5    
  217. XCOPYRIGHT                  4    
  218. XFILES                      1    
  219. XINSTALL                    1    
  220. XINSTALLREADABLE            2    
  221. XMakefile                   5    
  222. XQUESTIONS                  4    
  223. XTESTS                      4    
  224. Xconfig.h                   3    
  225. Xerr.c                      5    
  226. Xerr.h                      6    
  227. Xfile.h                     6    
  228. Xfile.h.new                 6    
  229. Xfile.h.old                 5    
  230. Xgetopt.h                   6    
  231. Xglobals.c                  5    
  232. Xlogs.c                     3    
  233. Xlogs.h                     6    
  234. Xmaster.c                   2    
  235. Xmaster.h                   6    
  236. Xmisc.c                     5    
  237. Xmisc.h                     6    
  238. Xpatch                      1    
  239. Xpatch/Makefile             4    
  240. Xpatch/README               4    
  241. Xpatch/TELNET.FTP           6    
  242. Xpatch/igntt.c              5    
  243. Xpatch/telnetd.90.06.28.patch  1    
  244. Xpty.1                      3    
  245. Xpty.c                      2    
  246. Xpty.h                      5    
  247. Xsig.c                      4    
  248. Xsig.h                      5    
  249. Xsigler.c                   3    
  250. Xsigler.h                   6    
  251. Xslave.c                    4    
  252. Xslave.h                    6    
  253. Xsock.c                     3    
  254. Xsock.h                     5    
  255. Xtexts.c                    4    
  256. Xtexts.h                    6    
  257. Xtty.c                      3    
  258. Xtty.h                      5    
  259. Xutil                       1    
  260. Xutil/Makefile              3    
  261. Xutil/biff.1                5    
  262. Xutil/biff.c                4    
  263. Xutil/condom                6    
  264. Xutil/condom.1              5    
  265. Xutil/disconnect.1          5    
  266. Xutil/disconnect.c          5    
  267. Xutil/excloff.1             6    
  268. Xutil/excloff.c             6    
  269. Xutil/exclon.1              5    
  270. Xutil/exclon.c              6    
  271. Xutil/lock.1                5    
  272. Xutil/lock.c                5    
  273. Xutil/mesg.1                5    
  274. Xutil/mesg.c                5    
  275. Xutil/reconnect.1           5    
  276. Xutil/reconnect.c           5    
  277. Xutil/script                6    
  278. Xutil/script.1              5    
  279. Xutil/script.tidy           6    
  280. Xutil/script.tidy.1         5    
  281. Xutil/sess                  6    
  282. Xutil/sess.1                5    
  283. Xutil/sesskill.1            5    
  284. Xutil/sesskill.c            5    
  285. Xutil/sesslist.1            5    
  286. Xutil/sesslist.c            4    
  287. Xutil/sessname.1            5    
  288. Xutil/sessname.c            5    
  289. Xutil/sessuser.1            4    
  290. Xutil/sessuser.c            4    
  291. Xutil/sessutil.c            4    
  292. Xutil/sessutil.h            5    
  293. Xutil/tiocsti.1             6    
  294. Xutil/tiocsti.c             6    
  295. Xutil/tty.1                 6    
  296. Xutil/tty.c                 6    
  297. Xutil/u.1                   5    
  298. Xutil/u.c                   5    
  299. Xutil/wall.1                5    
  300. Xutil/wall.c                5    
  301. Xutil/who.1                 5    
  302. Xutil/who.c                 5    
  303. Xutil/write.1               5    
  304. Xutil/write.c               4    
  305. Xutil/xsessutil.c           4    
  306. END_OF_FILE
  307.   if test 2906 -ne `wc -c <'MANIFEST'`; then
  308.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  309.   fi
  310.   # end of 'MANIFEST'
  311. fi
  312. if test -f 'FILES' -a "${1}" != "-c" ; then 
  313.   echo shar: Will not clobber existing file \"'FILES'\"
  314. else
  315.   echo shar: Extracting \"'FILES'\" \(1052 characters\)
  316.   sed "s/^X//" >'FILES' <<'END_OF_FILE'
  317. XCHANGES
  318. XREADME
  319. XFILES
  320. XCOPYRIGHT
  321. XMANIFEST
  322. XINSTALL
  323. XINSTALLREADABLE
  324. XTESTS
  325. XQUESTIONS
  326. XMakefile
  327. Xpty.1
  328. Xconfig.h
  329. Xpty.h
  330. Xsigler.h
  331. Xmaster.h
  332. Xslave.h
  333. Xerr.h
  334. Xtty.h
  335. Xgetopt.h
  336. Xtexts.h
  337. Xsig.h
  338. Xlogs.h
  339. Xfile.h
  340. Xfile.h.old
  341. Xfile.h.new
  342. Xsock.h
  343. Xmisc.h
  344. Xpty.c
  345. Xsigler.c
  346. Xmaster.c
  347. Xslave.c
  348. Xerr.c
  349. Xtty.c
  350. Xtexts.c
  351. Xsig.c
  352. Xglobals.c
  353. Xlogs.c
  354. Xsock.c
  355. Xmisc.c
  356. Xpatch
  357. Xpatch/README
  358. Xpatch/TELNET.FTP
  359. Xpatch/Makefile
  360. Xpatch/telnetd.90.06.28.patch
  361. Xpatch/igntt.c
  362. Xutil
  363. Xutil/Makefile
  364. Xutil/biff.1
  365. Xutil/biff.c
  366. Xutil/condom
  367. Xutil/condom.1
  368. Xutil/disconnect.1
  369. Xutil/disconnect.c
  370. Xutil/excloff.1
  371. Xutil/excloff.c
  372. Xutil/exclon.1
  373. Xutil/exclon.c
  374. Xutil/lock.1
  375. Xutil/lock.c
  376. Xutil/mesg.1
  377. Xutil/mesg.c
  378. Xutil/reconnect.1
  379. Xutil/reconnect.c
  380. Xutil/script
  381. Xutil/script.1
  382. Xutil/script.tidy
  383. Xutil/script.tidy.1
  384. Xutil/sess
  385. Xutil/sess.1
  386. Xutil/sesskill.1
  387. Xutil/sesskill.c
  388. Xutil/sesslist.1
  389. Xutil/sesslist.c
  390. Xutil/sessname.1
  391. Xutil/sessname.c
  392. Xutil/sessuser.1
  393. Xutil/sessuser.c
  394. Xutil/sessutil.c
  395. Xutil/sessutil.h
  396. Xutil/tiocsti.1
  397. Xutil/tiocsti.c
  398. Xutil/tty.1
  399. Xutil/tty.c
  400. Xutil/u.1
  401. Xutil/u.c
  402. Xutil/wall.1
  403. Xutil/wall.c
  404. Xutil/who.1
  405. Xutil/who.c
  406. Xutil/write.1
  407. Xutil/write.c
  408. Xutil/xsessutil.c
  409. END_OF_FILE
  410.   if test 1052 -ne `wc -c <'FILES'`; then
  411.     echo shar: \"'FILES'\" unpacked with wrong size!
  412.   fi
  413.   # end of 'FILES'
  414. fi
  415. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  416.   echo shar: Will not clobber existing file \"'INSTALL'\"
  417. else
  418.   echo shar: Extracting \"'INSTALL'\" \(25242 characters\)
  419.   sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  420. X#!/bin/sh
  421. X# This is a shell script. Feed it to sh.
  422. Xecho '
  423. XHi, and welcome to the pty install script.
  424. Xpty is a program for managing pseudo-terminals.
  425. X
  426. XI'\''m not actually going to install anything.
  427. XI'\''ll just guide you through what has to be done,
  428. Xfrom compiling through installation.
  429. X
  430. XOne advantage of this hands-off philosophy is that
  431. Xyou can kill and restart this script at any time.
  432. XYou may prefer to read through INSTALLREADABLE,
  433. Xwhich has the same information.
  434. X
  435. XIn the first part of this script, I'\''ll lead you through configuration.
  436. XFor the moment, don'\''t actually change anything in your system. Just
  437. Xalternate between reading this script and fooling around with the
  438. XMakefile, and I'\''ll remind you later, after compilation, of what has
  439. Xto be changed elsewhere.
  440. X
  441. XI need the following programs: echo, tr [-d], man, sed [-n], grep, test.
  442. X'
  443. X
  444. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  445. X
  446. Xecho '
  447. XThe first versions of pty were designed on a BSD 4.2-based system.
  448. XDuring May 1990 pty 3.0 was written completely from scratch,
  449. Xon a BSD 4.3-based system. It has been thoroughly tested on
  450. Xseveral BSD 4.3-based systems, tested with a few Makefile changes
  451. Xon several BSD 4.2-based systems, and run on at least one mutant.
  452. X
  453. XIf you make it through installation and testing and get pty running,
  454. Xplease send a note to the author, Dan Bernstein, on the Internet
  455. Xat brnstnd@nyu.edu. Let him know your computer model, OS version, and
  456. Xwhat changes you had to make. If you have any trouble, please also get
  457. Xin touch with the author. If you have a different kind of system with
  458. Xpseudo-terminal support that could use a pty port, the author would
  459. Xlove to hear about it.
  460. X
  461. XOne note: Like all software, pty comes without warranty, to the extent
  462. Xpermitted by applicable law. Use it at your own risk.
  463. X'
  464. X
  465. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  466. X
  467. Xecho '
  468. XI assume that you don'\''t want to make any major changes
  469. Xto your computer just to take advantage of pty'\''s capabilities.
  470. XYou might not even have a privileged account, for all I know.
  471. X
  472. XThe first major decision you have to make is what privileges to give pty.
  473. XObviously if you don'\''t have privileges then pty won'\''t either;
  474. Xthis is Case UN.
  475. X'
  476. X
  477. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  478. X
  479. Xecho '
  480. XThere are several good reasons for giving programs privileges.
  481. XMost importantly, privileged programs can precisely control access
  482. Xto a shared resource. pty supports an interactive user list in
  483. X/etc/utmp, a login-logout record in /usr/adm/wtmp, and controlled
  484. Xaccess to the pseudo-terminal files themselves, including security and
  485. Xmode changing. None of these are possible if pty isn'\''t setuid.
  486. X
  487. XIf your system has a lot more tty security than usual, you probably
  488. Xwon'\''t be able to run pty without privileges. (However, if your system
  489. Xhas a lot more tty security than usual, it'\''s almost certainly running
  490. Xpty anyway.)
  491. X'
  492. X
  493. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  494. X
  495. Xecho '
  496. XIf you do want pty to have privileges, you have to decide between
  497. Xsetting up pty as root (Case ROOT) or as some other user, say ``pty'\'\''
  498. X(Case PTY). Staying away from root has the advantage that problems
  499. Xcan'\''t possibly destroy all security in one blow. However, root has
  500. Xseveral advantages, mainly because of BSD limitations: 1. A process
  501. Xcan'\''t change ownership of a file between its euid and uid. Only root
  502. Xcan change ownership. It shouldn'\''t be necessary to change ownership
  503. Xof ptys anyway, but that'\''s what many programs assume. 2. MAXUPRC in
  504. X<sys/param.h> limits the number of processes under a given *effective*
  505. Xuid. This absolutely idiotic behavior is a serious problem for programs
  506. Xsetuid to anything other than root. pty tries to work around this
  507. Xproblem, but there are no true solutions. 3. Despite the documentation
  508. Xin kill(2), many machines don'\''t allow non-root processes to send
  509. XCONT to children with a different uid. Unlike almost all other programs,
  510. Xpty sensibly handles its child stopping and restarting; but this won'\''t
  511. Xwork on those machines if pty isn'\''t root.
  512. X
  513. XYou should decide now between Case ROOT and Case PTY.
  514. X'
  515. X
  516. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  517. X
  518. Xecho '
  519. XWhether you'\''ve decided on ROOT, PTY, or UN,
  520. Xnow is the time to check the security of the entire pty package.
  521. XIt'\''d be difficult for anything to slip through the checks by the
  522. Xauthor, testers, and source group moderator, but you should take
  523. Xat least a moment to look for your pet security peeves.
  524. X
  525. XA couple of security notes: The only open(,O_CREAT) in pty is in
  526. Xmaster.c, at the top of master(), of a file with a very restricted
  527. Xform constructed from the filename of a /dev/ttyxx. There are no
  528. Xcreat()s. The only bind() is in sock.c'\''s pty_readsock(), which is
  529. Xcalled only from master.c'\''s master() to create a socket with a
  530. Xsimilarly restricted name. (fnsty is changed in sigler but not in
  531. Xmaster.) The only exec() is in slave.c, after a forced setreuid()
  532. Xto a uid that is only set to getuid(). unlink(), mkdir(), and rename()
  533. Xare only used with restricted pathnames.
  534. X'
  535. X
  536. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  537. X
  538. Xecho '
  539. XIn Case PTY, you have to set up a new uid, say ``pty'\'\'' (or whatever
  540. Xusername you want). pty should not allow logins. Its password should
  541. Xbe an asterisk; its home directory should be /nonexistent; its shell
  542. Xshould be /bin/true. In other words, the only access to user pty
  543. Xshould be through these setuid programs.
  544. X
  545. XIn any privileged case you should have group tty,
  546. Xwhich most BSD 4.3 systems have as gid 4. 
  547. X'
  548. X
  549. Xecho 'Running '\
  550. X'$ ttygroup="`sed -n '\''s/^tty:[^:]*:\(.*\):.*/\1/p'\'' < /etc/group`" ...'
  551. Xttygroup="`sed -n 's/^tty:[^:]*:\(.*\):.*/\1/p' < /etc/group`"
  552. X
  553. Xcase "$ttygroup" in
  554. X4) echo '
  555. XI see that you have a tty group, 4 as usual. Good.
  556. X' ;;
  557. X'') echo '
  558. XYou don'\''t have a tty group. Unless you have a suitable group under a
  559. Xdifferent name, you should add the line
  560. Xtty:*:4:root
  561. Xto /etc/group.
  562. X' ;;
  563. X*) echo '
  564. XI see that you have a tty group, gid '"$ttygroup"' rather than 4. Okay.
  565. X' ;;
  566. Xesac
  567. X
  568. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  569. X
  570. Xecho '
  571. XNext, we'\''re going to drudge through the config.h file.
  572. X
  573. XIn Cases ROOT or PTY, you have to set up a system-wide directory
  574. Xfor storing information about pty sessions. (A session is a program
  575. Xstuck under a pty that you can disconnect and reconnect.) Users can
  576. Xget around this directory, storing the information in ~/.pty and
  577. Xrevoking any privileges, with pty -xS; you can even make this default
  578. Xby setting flagxsetuid = 0 in globals.c. However, a single system-wide
  579. Xdirectory is safer.
  580. X
  581. XAnyway, that directory, PTYDIR, should be mode 0700, owner root in case
  582. XROOT or pty in case PTY, group irrelevant. PTYDIR is defined in config.h
  583. Xas /usr/etc/pty by default; if you choose a different directory, add
  584. X-DPTYDIR=\"/what/ever/dir/ect/ory\" to CCOPTS in the Makefile.
  585. X
  586. XIn Case UN, you may want to set up a directory ~/PTY inside your home
  587. Xdirectory, and set PTYDIR to that; you may want to set flagxsetuid = 0
  588. Xin globals.c; or you may want to just type -xS to pty all the time. I
  589. Xrecommend the first strategy.
  590. X'
  591. X
  592. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  593. X
  594. Xecho '
  595. XNext come pseudo-terminal pathnames. I assume that your ptys are
  596. Xlabelled as /dev/ptyxx and /dev/ttyxx, where xx is any two-letter
  597. Xextension. pty can support any initial strings instead of these,
  598. Xbut some of the utilities have /dev/tty hardcoded, and lots of other
  599. Xprograms running around assume those names. If you'\''re desperate,
  600. Xdefine DEVMTY and DEVSTY in the Makefile, and figure out what has to
  601. Xbe changed in util/*. (Sorry.)
  602. X'
  603. X
  604. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  605. X
  606. Xecho '
  607. XThe extension is traditionally [p-za-o][0-9a-f]. The first letter of the
  608. Xsecond string is special: if /dev/ttyq0 doesn'\''t exist, for example, then
  609. Xnone of /dev/ttyq[0-9a-f] will be used. (That'\''s called a pty bank.)
  610. X
  611. XYou can change those strings by defining, e.g., PTY1=\"ABCDEFG\" or
  612. XPTY2=\"02468abfq\" in the Makefile. You have at least four choices here:
  613. X1. Give pty its own, new, banks of new pseudo-terminals with weird bank
  614. Xnames not including a through z, and define PTY1 appropriately. pty will
  615. Xonly use those new ptys, and older programs will just use the old ptys.
  616. XThis may require reconfiguring your system for the larger number of
  617. Xterminals. 2. Give pty some new banks, and take out some old ones to
  618. Xmake up for it. 3. Give pty a chunk of the old banks. 4. Give pty all
  619. Xthe old banks.
  620. X
  621. XNote that pty searches randomly through PTY1 and PTY2 by default; for
  622. Xefficiency, PTY1 really should reflect exactly the pty banks you have.
  623. X'
  624. X
  625. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  626. X
  627. Xecho '
  628. XSo now you'\''ve decided on new ptys, or set aside some or all of your
  629. Xold ptys, and changed PTY1 and PTY2 appropriately. Because BSD gives a
  630. Xprocess very little control over its controlling terminal, pty has to
  631. Xpass a terminal name explicitly when it reconnects. If any of your tty
  632. X(not just pseudo-tty!) filenames are longer than 30 characters, you have
  633. Xto set -DTTYNAMELEN=60 (or whatever) in the Makefile.
  634. X'
  635. X
  636. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  637. X
  638. Xecho '
  639. X/etc/utmp has traditionally listed all users logged on.
  640. XThis nebulous concept has evolved through the years; given the way
  641. Xthat most programs use utmp, utmp is probably better defined as a
  642. Xlist of all interactive sessions. Anyway, pty supports this file,
  643. Xand will make an entry in it when given -xu. If you have a different
  644. Xfile, add -DPTYUTMP_FILE=\"/foo/bar/utmp\" to DEFINES in the Makefile.
  645. X
  646. XNote that /etc/utmp is unprotected (mode 666) on Suns. This was Sun'\''s
  647. Xattempt to let unprivileged programs manage the file. Unforunately, this
  648. Xerror in judgment opens up a huge security hole, which even on
  649. Xsingle-user machines is an invitation to make mistakes. I advise you to
  650. Xmake /etc/utmp owned by root in Case ROOT or pty in Case PTY, mode 644.
  651. XThere aren'\''t many unprivileged programs that don'\''t understand the
  652. Xpty interface; people on non-Suns have survived so far, and there'\''s
  653. Xno reason for you to keep subscribing to an insecure model of resource
  654. Xsharing.
  655. X'
  656. X
  657. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  658. X
  659. Xecho '
  660. XAlthough pty will put an entry into utmp, it doesn'\''t really support
  661. Xthe remote-host field. There is no logical association between sessions
  662. Xand connections; why should a login require a pty, and why should a
  663. Xsession only stick around for one connection? So pty just puts "pty" in
  664. Xthe host field. You can change this with -DPTYUTMP_HOST=\"foo\"; you may
  665. Xeven want to make PTY_UTMPHOST call a function that you define.
  666. X
  667. X(Similar comments apply to PTYWTMP_HOST. There are also PTYUTMP_SWHOST
  668. Xand PTYWTMP_SWHOST, defaults PTYUTMP_HOST and "pty-sessuser"
  669. Xrespectively; see util/sessuser.1 for more information.)
  670. X'
  671. X
  672. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  673. X
  674. Xecho '
  675. X/usr/adm/wtmp has traditionally recorded all logins, logouts, reboots,
  676. Xftp sessions, and various other interesting events. (The entry for a
  677. Xline in utmp is the last entry for that line in wtmp.) pty supports wtmp
  678. Xfully, in the same way as utmp. You should make wtmp mode 644, owner
  679. Xroot or pty as appropriate. Change PTYWTMP_FILE if /usr/adm/wtmp is
  680. Xsomewhere else.
  681. X'
  682. X
  683. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  684. X
  685. Xecho '
  686. XYou can turn off utmp support by uncommenting the NO_UTMP line in
  687. Xconfig.h. (Just delete the initial /*.) You can also turn off support
  688. Xfor wtmp, disconnectable sessions, or changing pseudo-terminal file
  689. Xownership; just uncomment the appropriate line. You can force use of
  690. Xeach of these features by defining MUST_UTMP, etc., in the same way.
  691. X
  692. XNote that the usual login programs do their own wtmp management, and
  693. Xmany accounting programs incorrectly equate session time with connect
  694. Xtime, so users will rarely want wtmp. As more programs appear using the
  695. Xpty interface, and as login programs start using a more logical system
  696. Xfor accounting, MUST_WTMP may become an appropriate way to monitor
  697. Xpseudo-terminal usage. For the moment, I do not advise setting any NO
  698. Xor MUST.
  699. X'
  700. X
  701. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  702. X
  703. Xecho '
  704. Xpty subscribes (not very willingly) to the BSD 4.3 model of pty
  705. Xprotection, with a few twists. All ptys are under group tty, at all
  706. Xtimes; if you don'\''t have a tty group, all ptys should be under some
  707. Xother protected group at all times. Anyway, pty will change the group of
  708. Xeach pseudo-terminal file to PTYGROUP, default 4, under -xc.
  709. X'
  710. X
  711. Xcase "$ttygroup" in
  712. X4) echo '
  713. XSince you already have a tty group, gid 4, you'\''re fine.
  714. X' ;;
  715. X'') echo '
  716. XYou don'\''t have a tty group. You should pick a gid and define
  717. X-DPTYGROUP=whatever in the Makefile.
  718. X' ;;
  719. X*) echo '
  720. XYou have a tty group, but it'\''s not gid 4. You should define
  721. X-DPTYGROUP='"$ttygroup"' in the Makefile.
  722. X' ;;
  723. Xesac
  724. X
  725. Xecho '
  726. X(Under Case UN, don'\''t worry about all this group stuff. Just leave
  727. XPTYGROUP alone.)
  728. X'
  729. X
  730. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  731. X
  732. Xecho '
  733. XUnder -xc, pty changes the pseudo-terminal owner to the current real
  734. Xuid. The fact that terminals need to be in the file hierarchy reflects a
  735. Xserious failure in the BSD terminal model; but anyway, many programs
  736. Xexpect to be able to fool around with /dev/tty. After pty is done with
  737. Xthe terminal, it sets the owner back to its effective uid. You can
  738. Xmodify this behavior by changing PTYOWNER from euid to something else.
  739. X
  740. XUnder Case UN, PTYOWNER is irrelevant.
  741. X'
  742. X
  743. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  744. X
  745. Xecho '
  746. XWhile a tty is unused, BSD systems traditionally leave it unprotected.
  747. XUnfortunately, this leaves some huge security holes. Here'\''s one of
  748. Xthe biggest advantages of a privileged pty manager: unused ttys don'\''t
  749. Xhave to be left open for any random program to use. After it'\''s done
  750. Xwith a pseudo-terminal, pty changes it to mode UNUSEDPTYMODE, default
  751. X0600. (This is another case of a poor model for kludging pty support
  752. Xinto unprivileged programs. If you haven'\''t set up separate pty banks
  753. Xfor pty, and you really want to allow unprivileged access to unused
  754. Xptys, try mode 0660 and make those other programs setgid to tty.)
  755. X
  756. XA tty that someone'\''s using can be in many different modes. Typically
  757. XUSEDPTYMODE should be 0600, which means user-only access, messages off,
  758. Xbiff off. If you really, really, really want to make the mistake of
  759. Xhaving messages or biff on by default, try 0620, 0700, or 0720. Note
  760. Xthat the world protection should always be 0: the point of the tty group
  761. Xis that only setgid-tty programs can access ttys.
  762. X
  763. XAs usual, you can'\''t do anything about these in Case UN.
  764. X'
  765. X
  766. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  767. X
  768. Xecho '
  769. XNow we'\''re past generic configuration and down to your system'\''s
  770. Xnitty-gritty.
  771. X
  772. XFor purity, pty has SIGRET_TYPE, default int, as the type returned by a
  773. Xsignal handler. On Suns and ANSI-compliant machines, you should define
  774. XSIGRET_TYPE=void. Then you can admire the lint -haxc *.c output.
  775. X'
  776. X
  777. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  778. X
  779. Xecho '
  780. XOUTBUFSIZE, default 16384, is the size of the buffer pty keeps between
  781. Xthe incoming data and the pseudo-tty, and between the pseudo-tty and the
  782. Xoutgoing data. If you want to spare less than 32K per pty just for
  783. Xbuffer space, feel free to change this.
  784. X'
  785. X
  786. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  787. X
  788. Xecho '
  789. XGENERIC is another concession to ANSI taste. GENERIC * should be a
  790. Xpointer type that any other pointer can be safely converted to and back;
  791. XGENERIC is char by default, but on newer machines can be set to void.
  792. XAs it'\''ll be at least five years before ANSI manages to outlaw char *,
  793. Xand as void * is often invalid, I advise you to leave GENERIC alone.
  794. X'
  795. X
  796. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  797. X
  798. Xecho '
  799. Xpty attempts to forward window-size changes transparently. It also
  800. Xsupports the auxiliary characters structure, which lets you type a
  801. Xsingle character to get system and tty status.
  802. X'
  803. X
  804. Xecho 'Running $ man 4 tty | sed '\''s/_//g'\'' | grep -s winsize'
  805. Xif man 4 tty | sed 's/_//g' | grep -s winsize
  806. Xthen havewin=y; echo '
  807. XI see you have window sizes.
  808. X'
  809. Xelse havewin=n; echo '
  810. XI see you don'\''t have window sizes.
  811. XYou'\''ll have to comment out #define TTY_WINSIZE in config.h.
  812. X(This may be inaccurate on Suns; try grep winsize /usr/include/sys/tt*.h.)
  813. X' 
  814. X     case "$ttygroup" in
  815. X     4) ;;
  816. X     '') echo '(Let me guess: This isn'\''t a BSD 4.3 system.)' ;;
  817. X     *) ;;
  818. X     esac
  819. Xfi
  820. X
  821. Xecho 'Running $ man 4 tty | sed '\''s/_//g'\'' | grep -s auxchars'
  822. Xif man 4 tty | sed 's/_//g' | grep -s auxchars
  823. Xthen haveaux=y; echo '
  824. XI see you have auxiliary characters.
  825. XYou should uncomment #define TTY_AUXCHARS in config.h.
  826. X'
  827. Xelse haveaux=n; echo '
  828. XI see you don'\''t have auxiliary characters.
  829. X'
  830. Xfi
  831. X
  832. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  833. X
  834. Xecho '
  835. Xpty also puts siginterrupt() and usleep() to good use in working
  836. Xaround BSD limitations. Without siginterrupt(), there is absolutely
  837. Xno way to get per-process non-blocking I/O, so pty may block when it
  838. Xdoesn'\''t have to (namely, when it has N bytes to write to the output,
  839. Xthe output is a pipe with M bytes of space, and N > M > 0). If you
  840. Xdefine SIGINTERRUPT (as default), pty will take some extra effort to
  841. Xnever, ever, ever block when it doesn'\''t have to.
  842. X
  843. XAt one point, pty pauses to kludge around a common bug in UNIX-domain
  844. Xsockets. With usleep() it will pause much more briefly. This makes
  845. Xreconnects much faster.
  846. X'
  847. X
  848. Xecho 'Running $ man siginterrupt | sed '\''s/_//g'\'' | grep -s siginterrupt'
  849. Xif man siginterrupt | sed 's/_//g' | grep -s siginterrupt
  850. Xthen havesigintr=y; echo '
  851. XI see you have siginterrupt(). Good.
  852. X'
  853. X     case "$ttygroup$havewinsize" in
  854. X     4y) echo 'I'\''ll bet you'\''re a BSD 4.3 system.' ;;
  855. X     *) echo 'Weird, are you BSD 4.3?' ;;
  856. X     esac
  857. Xelse havesigintr=n; echo '
  858. XI see you don'\''t have siginterrupt(). You have to comment out
  859. X#define SIGINTERRUPT in config.h.
  860. X'
  861. Xfi
  862. X
  863. Xecho 'Running $ man usleep | sed '\''s/_//g'\'' | grep -s usleep'
  864. Xif man usleep | sed 's/_//g' | grep -s usleep
  865. Xthen haveusleep=y; echo '
  866. XI see you have usleep(). Good.
  867. X'
  868. Xelse haveusleep=n; echo '
  869. XI see you don'\''t have usleep(). You have to comment out
  870. X#define USLEEP in config.h.
  871. X'
  872. Xfi
  873. X
  874. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  875. X
  876. Xecho '
  877. XFinally (almost done with configuration!), we have to make sure that you
  878. Xhave UNIX-domain sockets, and check whether you have file descriptor
  879. Xpassing.
  880. X'
  881. X
  882. Xecho 'Running $ test -r /usr/include/sys/un.h'
  883. Xif test -r /usr/include/sys/un.h
  884. Xthen haveunsocks=y; echo '
  885. XI see you have UNIX-domain sockets. Good.
  886. X'
  887. X   echo 'Running $ man recvmsg | sed '\''s/_//g'\'' | grep -s rights'
  888. X   if man recvmsg | sed 's/_//g' | grep -s rights
  889. X   then havefdpass=y; echo '
  890. XI see you have file descriptor passing. Good. (Your fd passing may be
  891. Xbuggy, as it'\''s a relatively new, powerful, and rarely exploited
  892. Xfeature. If you have trouble, try defining NO_FDPASSING.)
  893. X'
  894. X   else havefdpass=n; echo '
  895. XI see you don'\''t have file descriptor passing. This isn'\''t a
  896. Xdisaster, though it means that reconnected sessions will be as
  897. Xinefficient as they are in programs other than pty, boo hoo hoo.
  898. XUncomment NO_FDPASSING in config.h.
  899. X'
  900. X   fi
  901. Xelse haveunsocks=n; echo '
  902. XUh-oh. I don'\''t see <sys/un.h>, which means you probably don'\''t have
  903. XUNIX-domain sockets. Without sockets you can'\''t have disconnectable
  904. Xsessions. Sigh. I guess you have to define NO_UNIXSOCKS in config.h.
  905. X'
  906. Xfi
  907. X
  908. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  909. X
  910. Xecho '
  911. XWhew! We'\''ve finally made it through configuration. If you want, try
  912. Xrunning lint -haxc *.c or whatever your favorite code checker is; the
  913. Xlint here gives some bogus errors about correct char * casts, an error
  914. Xbecause the SIG_IGN definition is unportable, and a couple of bzero
  915. Xcomplaints because FD_ZERO isn'\''t defined very well.
  916. X
  917. XIf you'\''re on an old system without FD_ZERO, FD_SET, and FD_ISSET in
  918. X<sys/types.h>, I recommend you upgrade. Try copying file.h.old to file.h
  919. X(the original version is in file.h.new).
  920. X
  921. XWe'\''re nearly at the end. Change CC and CCOPTS in the Makefile for any
  922. Xlast-minute additions; if you'\''re worried, change -s to -g for debugging.
  923. XNow compile! % (date; make) >>& Makelog & and come back to this script.
  924. X'
  925. X
  926. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  927. X
  928. Xecho '
  929. XWhile the program is compiling, let'\''s start providing some support.
  930. X(If the compile finishes or has an error, just ignore it for the
  931. Xmoment.) These are some real changes, so watch out!
  932. X
  933. XFirst---in Case PTY only!---make a new uid, pty, not allowing logins.
  934. X
  935. X/etc/passwd:  pty:*:whatever:4:::/bin/true
  936. X'
  937. X
  938. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  939. X
  940. Xecho '
  941. XSecond, make sure you have a tty group set up.
  942. X
  943. X/etc/group:  tty:*:4:root
  944. X'
  945. X
  946. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  947. X
  948. Xecho '
  949. XThird, make PTYDIR.
  950. X
  951. XROOT: # mkdir /usr/etc/pty; chmod 700 /usr/etc/pty
  952. XPTY: # mkdir /usr/etc/pty; chown pty /usr/etc/pty; chmod 700 /usr/etc/pty
  953. XUN: % mkdir ~/PTY; chmod 700 ~/PTY
  954. X'
  955. X
  956. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  957. X
  958. Xecho '
  959. XFourth, make sure you have all the pseudo-terminal files set up and
  960. Xappropriately configured.
  961. X
  962. XChange each of them to group tty.
  963. X
  964. XChange each of them to owner pty in case PTY or root in case ROOT.
  965. X
  966. XChange each of them to mode UNUSEDPTYMODE (0600).
  967. X'
  968. X
  969. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  970. X
  971. Xecho '
  972. XFifth, make sure /etc/utmp and /usr/adm/wtmp exist, owned by root in
  973. XCase ROOT or pty in Case PTY, each mode 644. (In Case UN, you probably
  974. Xwant to be working on a Sun with its insecure /etc/utmp, so that pty can
  975. Xtake advantage of it. Sigh.)
  976. X'
  977. X
  978. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  979. X
  980. Xecho '
  981. XSixth, I advise that you make a special directory /usr/local/ptybin for
  982. Xpty and its associated utilities, with symbolic links in /usr/local.
  983. XThis choice isn'\''t too important, but it'\''s easier if you know a
  984. Xplace to put programs.
  985. X'
  986. X
  987. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  988. X
  989. Xecho '
  990. XOkay. You'\''ve done about all that can be done before compilation
  991. Xfinishes, so go do something else.
  992. X'
  993. X
  994. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  995. X
  996. Xecho '
  997. XThe compile should be done now. If all went well, the make should have
  998. Xexited normally, Makelog should show no errors, and you should have an
  999. Xexecutable pty program sitting in this directory. Unfortunately, life
  1000. Xisn'\''t always so generous. Here are a few of the more common errors.
  1001. X
  1002. XThe loader complains about missing getopt(), optarg, and optind: These
  1003. Xare all in the getopt library, available in the early volumes of
  1004. Xcomp.sources.unix. If you use GNU getopt, please make sure you
  1005. Xunderstand the implications of its license.
  1006. X
  1007. XThe loader complains about missing FD_ZERO, FD_SET, and FD_ISSET: Try
  1008. Xcopying file.h.old to file.h and recompiling. If the compiler gives
  1009. Xvarious further errors related to these macros, uncomment the
  1010. Xcommented-out lines in file.h.old, copy to file.h, and try once again.
  1011. X
  1012. Xbcopy() isn'\''t defined: In pty.h, change bcopy(src,dst,num) to
  1013. Xmemcpy(dst,src,num). (Note the order.) Try again.
  1014. X
  1015. XIf you still can'\''t get the code to compile, let the author know.
  1016. X'
  1017. X
  1018. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  1019. X
  1020. Xecho '
  1021. XNext, compile the utilities. There isn'\''t much to say about them;
  1022. Xthey'\''re all public domain, some of them clones of or improvements
  1023. Xover standard utilities, some of them clones with special features to
  1024. Xwork with pty, some of them entirely new programs for pty'\''s new
  1025. Xfeatures. Just glance at the top of util/Makefile; then
  1026. X% cd util; (date; make) >>& Makelog & and wait.
  1027. X
  1028. XWarning: The pty session directory is hardcoded in util/sessutil.c.
  1029. XIf you have changed PTYDIR, check through sessutil.c carefully.
  1030. X'
  1031. X
  1032. Xecho '----- Press return to continue. ' | tr -d '\012'; read contline
  1033. X
  1034. Xecho '
  1035. XSo now you should have some executables sitting around collecting dust.
  1036. XIn Cases ROOT and PTY, put {pty,biff,disconnect,mesg,reconnect,sesskill,
  1037. Xsesslist,sessname,sessuser} into a system-wide directory, owner root or
  1038. Xpty, mode 4755. Put wall and write into the same place, group tty, mode
  1039. X2755. Put {condom,excloff,exclon,last,lock,script,script.tidy,sess,tiocsti,
  1040. Xtty,u,who,xdisconnect,xreconnect,xsesskill,xsesslist,xsessname,xsessuser}
  1041. Xinto the same place, mode 755. Make absolutely sure none of the shell
  1042. Xscripts are setuid.
  1043. X
  1044. XIn Case UN, just put all the programs somewhere in your PATH.
  1045. X
  1046. XThat'\''s it! Try running TESTS now.
  1047. X
  1048. X(Two other things you have to do at some point: move your old script,
  1049. Xbiff, mesg, and so on to script.old, biff.old, mesg.old, etc., with
  1050. Xsymbolic links to the new versions in their place; and move the old
  1051. X/usr/man/{script,biff,mesg,...}.1 somewhere else, copy all the *.1
  1052. Xhere to /usr/man/man1, and run /etc/catman.)
  1053. X'
  1054. END_OF_FILE
  1055.   echo shar: 10 control characters may be missing from \"'INSTALL'\"
  1056.   if test 25242 -ne `wc -c <'INSTALL'`; then
  1057.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  1058.   fi
  1059.   chmod +x 'INSTALL'
  1060.   # end of 'INSTALL'
  1061. fi
  1062. if test ! -d 'patch' ; then
  1063.     echo shar: Creating directory \"'patch'\"
  1064.     mkdir 'patch'
  1065. fi
  1066. if test -f 'patch/telnetd.90.06.28.patch' -a "${1}" != "-c" ; then 
  1067.   echo shar: Will not clobber existing file \"'patch/telnetd.90.06.28.patch'\"
  1068. else
  1069.   echo shar: Extracting \"'patch/telnetd.90.06.28.patch'\" \(13647 characters\)
  1070.   sed "s/^X//" >'patch/telnetd.90.06.28.patch' <<'END_OF_FILE'
  1071. X*** pathnames.h.original    Tue Aug 21 15:45:25 1990
  1072. X--- pathnames.h    Tue Aug 21 22:24:30 1990
  1073. X***************
  1074. X*** 35,37 ****
  1075. X--- 35,40 ----
  1076. X  #ifdef BFTPDAEMON
  1077. X  #define        BFTPPATH    "/usr/ucb/bftp"
  1078. X  #endif  /* BFTPDAEMON */
  1079. X+ #ifdef USEPTY
  1080. X+ #define _PATH_PTY "/usr/local/pty"
  1081. X+ #endif
  1082. X*** sys_term.c.original    Tue Aug 21 15:45:31 1990
  1083. X--- sys_term.c    Tue Aug 21 22:00:56 1990
  1084. X***************
  1085. X*** 23,28 ****
  1086. X--- 23,32 ----
  1087. X  
  1088. X  #include "telnetd.h"
  1089. X  #include "pathnames.h"
  1090. X+ #ifdef USEPTY
  1091. X+ #include "sock.h"
  1092. X+ extern char *ttyname();
  1093. X+ #endif
  1094. X  
  1095. X  #ifdef    NEWINIT
  1096. X  #include <initreq.h>
  1097. X***************
  1098. X*** 354,359 ****
  1099. X--- 358,364 ----
  1100. X  
  1101. X  getpty()
  1102. X  {
  1103. X+ #ifndef USEPTY
  1104. X      register int p;
  1105. X  #ifndef CRAY
  1106. X      register char c, *p1, *p2;
  1107. X***************
  1108. X*** 398,403 ****
  1109. X--- 403,416 ----
  1110. X      }
  1111. X  #endif    /* CRAY */
  1112. X      return(-1);
  1113. X+ #else USEPTY
  1114. X+ /* In this new 'n' improved pty-based telnetd, we've already called */
  1115. X+ /* startslave, which in turn waited to grab pseudo-terminals from the */
  1116. X+ /* pty program. Global variable pty (grrrr) already has our tty. line */
  1117. X+ /* has already been filled in by startslave. In fact, there's no point */
  1118. X+ /* in calling getpty() at all. */
  1119. X+  return pty;
  1120. X+ #endif USEPTY
  1121. X  }
  1122. X  
  1123. X  #ifdef    LINEMODE
  1124. X***************
  1125. X*** 764,772 ****
  1126. X--- 777,788 ----
  1127. X   */
  1128. X  getptyslave()
  1129. X  {
  1130. X+ #ifndef USEPTY
  1131. X      register int t = -1;
  1132. X+ #endif
  1133. X  
  1134. X  #ifndef    CRAY
  1135. X+ #ifndef USEPTY
  1136. X      /*
  1137. X       * Disassociate self from control terminal and open ttyp side.
  1138. X       * Set important flags on ttyp and ptyp.
  1139. X***************
  1140. X*** 791,796 ****
  1141. X--- 807,815 ----
  1142. X          fatalperror(net, line);
  1143. X  #endif
  1144. X  
  1145. X+ #else USEPTY
  1146. X+  /* In a pty-based world, this function is rendered similarly useless. */
  1147. X+ #endif USEPTY
  1148. X      init_termbuf();
  1149. X  #ifndef    USE_TERMIO
  1150. X      termbuf.sg.sg_flags |= CRMOD|ANYP|ECHO|XTABS;
  1151. X***************
  1152. X*** 812,821 ****
  1153. X--- 831,846 ----
  1154. X  #endif
  1155. X      set_termbuf();
  1156. X  #else    /* CRAY */
  1157. X+ #ifndef USEPTY
  1158. X      (void) chown(line, 0, 0);
  1159. X      (void) chmod(line, 0600);
  1160. X+ #endif
  1161. X  #endif    /* CRAY */
  1162. X+ #ifndef USEPTY
  1163. X      return(t);
  1164. X+ #else USEPTY
  1165. X+  /* What's there to return? We've thrown away fdsty. */
  1166. X+ #endif
  1167. X  }
  1168. X  
  1169. X  #ifdef    NEWINIT
  1170. X***************
  1171. X*** 829,842 ****
  1172. X--- 854,891 ----
  1173. X   * is necessary to startup the login process on the slave side of the pty.
  1174. X   */
  1175. X  
  1176. X+ #ifdef USEPTY
  1177. X+ int fdpass[2];
  1178. X+ int siglerpid;
  1179. X+ #endif USEPTY
  1180. X  /* ARGSUSED */
  1181. X+ #ifndef USEPTY
  1182. X  startslave(t, host)
  1183. X  int t;
  1184. X+ #else USEPTY
  1185. X+ startslave(host)
  1186. X+ #endif USEPTY
  1187. X  char *host;
  1188. X  {
  1189. X      register int i;
  1190. X      long time();
  1191. X  
  1192. X+ #ifdef USEPTY
  1193. X+  char strfdpass[10];
  1194. X+  char ch;
  1195. X+  int fdmty;
  1196. X+  int fdsty;
  1197. X+  char *ttyn;
  1198. X+  int pgrp;
  1199. X+  int fd;
  1200. X+ #endif USEPTY
  1201. X+ #ifdef USEPTY
  1202. X+  /* Prepare for receiving pseudo-terminal descriptors from pty. */
  1203. X+  if (socketpair(AF_UNIX,SOCK_STREAM,0,fdpass) == -1) /* virtually impossible */
  1204. X+    fatalperror(net,"pty-socketpair");
  1205. X+  (void) sprintf(strfdpass,"%d",fdpass[1]);
  1206. X+ 
  1207. X+ #endif USEPTY
  1208. X  #ifndef    NEWINIT
  1209. X  # ifdef    CRAY
  1210. X      utmp_sig_init();
  1211. X***************
  1212. X*** 845,850 ****
  1213. X--- 894,902 ----
  1214. X      if ((i = fork()) < 0)
  1215. X          fatalperror(net, "fork");
  1216. X      if (i) {
  1217. X+ #ifdef USEPTY
  1218. X+    siglerpid = i;
  1219. X+ #endif
  1220. X  # ifdef    CRAY
  1221. X          /*
  1222. X           * Cray parent will create utmp entry for child and send
  1223. X***************
  1224. X*** 873,881 ****
  1225. X--- 925,972 ----
  1226. X          }
  1227. X          utmp_sig_notify(pid);
  1228. X  # endif    /* CRAY */
  1229. X+ #ifndef USEPTY
  1230. X          (void) close(t);
  1231. X+ #else USEPTY
  1232. X+ /* Now we'll receive the descriptors. */
  1233. X+    (void) close(fdpass[1]);
  1234. X+    (void) sprintf(line,"/NONexistent");
  1235. X+    fdmty = fdsty = -1;
  1236. X+    if (pty_getch(fdpass[0],&ch) == -1)
  1237. X+      cleanup(); /* XXX: telnetd's finishup handling really sucks. */
  1238. X+    if (pty_putgetint(fdpass[0],'G',&siglerpid) == -1)
  1239. X+      cleanup();
  1240. X+    if (pty_getch(fdpass[0],&ch) == -1)
  1241. X+      cleanup();
  1242. X+    if (pty_putgetfd(fdpass[0],'m',&fdmty) == -1)
  1243. X+      cleanup();
  1244. X+    if (pty_getch(fdpass[0],&ch) == -1)
  1245. X+      cleanup();
  1246. X+    if (pty_putgetfd(fdpass[0],'s',&fdsty) == -1)
  1247. X+      cleanup();
  1248. X+    if (!(ttyn = ttyname(fdsty)))
  1249. X+      cleanup();
  1250. X+    (void) strncpy(line,ttyn,14);
  1251. X+    if ((fd = open("/dev/tty",O_RDWR)) != -1)
  1252. X+     {
  1253. X+      (void) ioctl(fd,TIOCNOTTY,0); /* detach */
  1254. X+      (void) close(fd);
  1255. X+     }
  1256. X+    (void) close(open(ttyn,O_RDWR)); /* attach ourselves to tty */
  1257. X+    pty = fdmty;
  1258. X+    (void) ioctl(fdsty,TIOCGPGRP,&pgrp);
  1259. X+    (void) setpgrp(0,pgrp);
  1260. X+    (void) close(fdsty); /* we won't need it for anything else */
  1261. X+    (void) fcntl(fdpass[0],F_SETFL,FNDELAY); /* XXX */
  1262. X+ 
  1263. X+ #endif USEPTY
  1264. X      } else {
  1265. X+ #ifndef USEPTY
  1266. X          start_login(t, host);
  1267. X+ #else USEPTY
  1268. X+    (void) close(fdpass[0]);
  1269. X+         start_login(host,strfdpass);
  1270. X+ #endif USEPTY
  1271. X          /*NOTREACHED*/
  1272. X      }
  1273. X  #else    /* NEWINIT */
  1274. X***************
  1275. X*** 986,994 ****
  1276. X--- 1077,1095 ----
  1277. X   * function will turn us into the login process.
  1278. X   */
  1279. X  
  1280. X+ #ifndef USEPTY
  1281. X  start_login(t, host)
  1282. X  int t;
  1283. X+ #else USEPTY
  1284. X+ /* Added parameter, for dealing with pty: strfdpass, a printable version */
  1285. X+ /* of the file descriptor for passing more descriptors up to us. */
  1286. X+ 
  1287. X+ start_login(host,strfdpass)
  1288. X+ #endif USEPTY
  1289. X  char *host;
  1290. X+ #ifdef USEPTY
  1291. X+ char *strfdpass;
  1292. X+ #endif USEPTY
  1293. X  {
  1294. X      register char *cp;
  1295. X      register char **argv;
  1296. X***************
  1297. X*** 996,1001 ****
  1298. X--- 1097,1103 ----
  1299. X  #ifdef    CRAY
  1300. X      register char **cpp, **cpp2;
  1301. X      utmp_sig_wait();
  1302. X+ #ifndef USEPTY
  1303. X  # ifndef TCVHUP
  1304. X      setpgrp();
  1305. X  # endif
  1306. X***************
  1307. X*** 1028,1038 ****
  1308. X--- 1130,1142 ----
  1309. X      termbuf.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
  1310. X      termbuf.c_cflag = EXTB|HUPCL|CS8;
  1311. X      set_termbuf();
  1312. X+ #endif USEPTY
  1313. X  #endif    /* CRAY */
  1314. X  
  1315. X      /*
  1316. X       * set up standard paths before forking to login
  1317. X       */
  1318. X+ #ifndef USEPTY
  1319. X  #ifndef    NO_SETSID
  1320. X      if (setsid() < 0)
  1321. X          fatalperror(net, "setsid");
  1322. X***************
  1323. X*** 1042,1053 ****
  1324. X--- 1146,1167 ----
  1325. X      if (ioctl(t, TIOCSCTTY, (char *)0) < 0)
  1326. X          fatalperror(net, "ioctl(sctty)");
  1327. X  #endif
  1328. X+ #else USEPTY
  1329. X+  /* The POSIXish setsid() handling here is pty's responsibility. */
  1330. X+ #endif USEPTY
  1331. X      (void) close(net);
  1332. X      (void) close(pty);
  1333. X+ #ifndef USEPTY
  1334. X      (void) dup2(t, 0);
  1335. X      (void) dup2(t, 1);
  1336. X      (void) dup2(t, 2);
  1337. X      (void) close(t);
  1338. X+ #else USEPTY
  1339. X+         (void) close(0); /* ahhh, life is easy */
  1340. X+         (void) close(1);
  1341. X+         (void) close(2);
  1342. X+     /* but absolutely don't close fdpass. */
  1343. X+ #endif USEPTY
  1344. X      /*
  1345. X       * -h : pass on name of host.
  1346. X       *        WARNING:  -h is accepted by login if and only if
  1347. X***************
  1348. X*** 1054,1060 ****
  1349. X--- 1168,1183 ----
  1350. X       *            getuid() == 0.
  1351. X       * -p : don't clobber the environment (so terminal type stays set).
  1352. X       */
  1353. X+ #ifdef USEPTY
  1354. X+  /* Stick the pty magic in front. */
  1355. X+  argv = addarg(0,   "pty"); /* this addarg stuff is stupid */
  1356. X+  argv = addarg(argv,"-sdf");
  1357. X+  argv = addarg(argv,strfdpass);
  1358. X+  argv = addarg(argv,"-xRCUWX"); /* XXX: -xr? */
  1359. X+  argv = addarg(argv,_PATH_LOGIN);
  1360. X+ #else
  1361. X      argv = addarg(0, "login");
  1362. X+ #endif
  1363. X      argv = addarg(argv, "-h");
  1364. X      argv = addarg(argv, host);
  1365. X  #if    !defined(CRAY) && !defined(NO_LOGIN_P)
  1366. X***************
  1367. X*** 1084,1090 ****
  1368. X--- 1207,1217 ----
  1369. X      }
  1370. X  #endif
  1371. X  
  1372. X+ #ifdef USEPTY
  1373. X+  execv(_PATH_PTY,argv);
  1374. X+ #else USEPTY
  1375. X      execv(_PATH_LOGIN, argv);
  1376. X+ #endif USEPTY
  1377. X  
  1378. X      syslog(LOG_ERR, "%s: %m\n", _PATH_LOGIN);
  1379. X      fatalperror(net, _PATH_LOGIN);
  1380. X***************
  1381. X*** 1142,1155 ****
  1382. X--- 1269,1294 ----
  1383. X      p = line + sizeof("/dev/") - 1;
  1384. X      if (logout(p))
  1385. X          logwtmp(p, "", "");
  1386. X+ #ifndef USEPTY
  1387. X      (void)chmod(line, 0666);
  1388. X+ #else USEPTY
  1389. X+     (void) chmod(line,0600); /* banish these security holes! */
  1390. X+ #endif USEPTY
  1391. X      (void)chown(line, 0, 0);
  1392. X      *p = 'p';
  1393. X+ #ifndef USEPTY
  1394. X      (void)chmod(line, 0666);
  1395. X+ #else USEPTY
  1396. X+     (void) chmod(line,0600);
  1397. X+ #endif USEPTY
  1398. X      (void)chown(line, 0, 0);
  1399. X  # else
  1400. X      rmut();
  1401. X+ #ifndef USEPTY
  1402. X      vhangup();    /* XXX */
  1403. X+ #else USEPTY
  1404. X+ /*    vhangup();        XXX: This is also pty's responsibility. */
  1405. X+ #endif USEPTY
  1406. X  # endif
  1407. X      (void) shutdown(net, 2);
  1408. X  #else    /* CRAY */
  1409. X***************
  1410. X*** 1156,1162 ****
  1411. X--- 1295,1306 ----
  1412. X  # ifndef NEWINIT
  1413. X      rmut(line);
  1414. X      (void) shutdown(net, 2);
  1415. X+ #ifndef USEPTY
  1416. X      kill(0, SIGHUP);
  1417. X+ #else USEPTY
  1418. X+ /* kill(0, SIGHUP);    The pty master makes this decision. */
  1419. X+  (void) kill(siglerpid,SIGHUP); /* but we do have to tell the sigler. */
  1420. X+ #endif USEPTY
  1421. X  # else    /* NEWINIT */
  1422. X      (void) shutdown(net, 2);
  1423. X  # endif    /* NEWINT */
  1424. X***************
  1425. X*** 1273,1282 ****
  1426. X--- 1417,1434 ----
  1427. X              (void) close(f);
  1428. X          }
  1429. X      }
  1430. X+ #ifndef USEPTY
  1431. X      (void) chmod(line, 0666);
  1432. X+ #else USEPTY
  1433. X+     (void) chmod(line, 0600);
  1434. X+ #endif USEPTY
  1435. X      (void) chown(line, 0, 0);
  1436. X      line[strlen("/dev/")] = 'p';
  1437. X+ #ifndef USEPTY
  1438. X      (void) chmod(line, 0666);
  1439. X+ #else USEPTY
  1440. X+     (void) chmod(line, 0600);
  1441. X+ #endif USEPTY
  1442. X      (void) chown(line, 0, 0);
  1443. X  }  /* end of rmut */
  1444. X  #endif    /* CRAY */
  1445. X*** telnetd.c.original    Tue Aug 21 15:45:36 1990
  1446. X--- telnetd.c    Tue Aug 21 21:27:48 1990
  1447. X***************
  1448. X*** 28,33 ****
  1449. X--- 28,37 ----
  1450. X  #endif /* not lint */
  1451. X  
  1452. X  #include "telnetd.h"
  1453. X+ #ifdef USEPTY
  1454. X+ #include "sock.h"
  1455. X+ extern char *ttyname();
  1456. X+ #endif USEPTY
  1457. X  
  1458. X  /*
  1459. X   * I/O data buffers,
  1460. X***************
  1461. X*** 462,467 ****
  1462. X--- 466,472 ----
  1463. X      int t;
  1464. X      struct hostent *hp;
  1465. X  
  1466. X+ #ifndef USEPTY
  1467. X      /*
  1468. X       * Find an available pty to use.
  1469. X       */
  1470. X***************
  1471. X*** 470,475 ****
  1472. X--- 475,481 ----
  1473. X          fatal(net, "All network ports in use");
  1474. X  
  1475. X      t = getptyslave();
  1476. X+ #endif USEPTY
  1477. X  
  1478. X      /* get name of connected client */
  1479. X      hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr),
  1480. X***************
  1481. X*** 489,500 ****
  1482. X--- 495,533 ----
  1483. X      /*
  1484. X       * Start up the login process on the slave side of the terminal
  1485. X       */
  1486. X+ #ifndef USEPTY
  1487. X      startslave(t, host);
  1488. X+ #else USEPTY
  1489. X+     startslave(host);
  1490. X+ #endif USEPTY
  1491. X  
  1492. X+ #ifdef USEPTY
  1493. X+ /* In this pty-based version of the world, life is easy. startslave() */
  1494. X+ /* actually dumps its process under the pty program, which handles all */
  1495. X+ /* those nasty details of finding a pty and getting it started. pty */
  1496. X+ /* then passes its pty master side up to telnetd (the ``controller'') */
  1497. X+ /* so that we have full control. Joy to the world. */
  1498. X+ 
  1499. X+     /*
  1500. X+      * Find an available pty to use.
  1501. X+      */
  1502. X+     pty = getpty(); /* noop */
  1503. X+     if (pty < 0) /* impossible */
  1504. X+         fatal(net, "All network ports in use");
  1505. X+ 
  1506. X+     getptyslave();
  1507. X+ 
  1508. X+ #endif USEPTY
  1509. X      telnet(net, pty);  /* begin server processing */
  1510. X      /*NOTREACHED*/
  1511. X  }  /* end of doit */
  1512. X  
  1513. X+ #ifdef USEPTY
  1514. X+ extern int fdpass[2];
  1515. X+ extern int siglerpid;
  1516. X+ char ch;
  1517. X+ 
  1518. X+ #endif USEPTY
  1519. X  #ifndef    MAXHOSTNAMELEN
  1520. X  #define    MAXHOSTNAMELEN 64
  1521. X  #endif    MAXHOSTNAMELEN
  1522. X***************
  1523. X*** 775,780 ****
  1524. X--- 808,819 ----
  1525. X          if (!SYNCHing) {
  1526. X              FD_SET(f, &xbits);
  1527. X          }
  1528. X+ #ifdef USEPTY
  1529. X+      FD_SET(fdpass[0],&ibits);
  1530. X+      /* When we get input on fdpass, we're switching ttys. */
  1531. X+      /* This FD_SET seems logical, but it invites bugs under many */
  1532. X+      /* implementations. XXX. */
  1533. X+ #endif USEPTY
  1534. X          if ((c = select(16, &ibits, &obits, &xbits,
  1535. X                          (struct timeval *)0)) < 1) {
  1536. X              if (c == -1) {
  1537. X***************
  1538. X*** 785,791 ****
  1539. X--- 824,899 ----
  1540. X              sleep(5);
  1541. X              continue;
  1542. X          }
  1543. X+ #ifdef USEPTY
  1544. X+         if (pty_getch(fdpass[0],&ch) != -1)
  1545. X+          {
  1546. X+           /* reconnect... */
  1547. X+           int fdmty;
  1548. X+           int fdsty;
  1549. X+           char *ttyn;
  1550. X+           int pgrp;
  1551. X+           int fd;
  1552. X  
  1553. X+           fdmty = fdsty = -1;
  1554. X+           (void) fcntl(fdpass[0],F_SETFL,0); /*XXX*/
  1555. X+           if (ch != 'G')
  1556. X+             if (pty_getch(fdpass[0],&ch) == -1)
  1557. X+               ;
  1558. X+           if (pty_putgetint(fdpass[0],'G',&siglerpid) == -1)
  1559. X+             cleanup();
  1560. X+           if (pty_getch(fdpass[0],&ch) == -1)
  1561. X+             cleanup();
  1562. X+           if (pty_putgetfd(fdpass[0],'m',&fdmty) == -1)
  1563. X+             cleanup();
  1564. X+           if (pty_getch(fdpass[0],&ch) == -1)
  1565. X+             cleanup();
  1566. X+           if (pty_putgetfd(fdpass[0],'s',&fdsty) == -1)
  1567. X+             cleanup();
  1568. X+           if (!(ttyn = ttyname(fdsty)))
  1569. X+             cleanup();
  1570. X+           /* It's impossible to do anything sensible with utmp; */
  1571. X+           /* this shows very clearly why utmp's remote field */
  1572. X+           /* is inconsistent. So we stick to the same ``line.'' */
  1573. X+ 
  1574. X+           fd = 0;
  1575. X+               (void) ioctl(p, TIOCPKT, (char *)&fd);
  1576. X+           /* Packet mode, like NDELAY, is not a polite thing to */
  1577. X+           /* give someone else. One of those unstated conventions */
  1578. X+           /* that people should learn... */
  1579. X+ 
  1580. X+           if ((fd = open("/dev/tty",O_RDWR)) != -1)
  1581. X+            {
  1582. X+             (void) ioctl(fd,TIOCNOTTY,0); /* detach */
  1583. X+             (void) close(fd);
  1584. X+            }
  1585. X+           (void) close(open(ttyn,O_RDWR)); /* attach */
  1586. X+ 
  1587. X+                   (void) close(pty);
  1588. X+           pty = fdmty;
  1589. X+           p = pty; /* XXX: Blame DAB for this. Whither modularity? */
  1590. X+ 
  1591. X+               (void) ioctl(p, TIOCPKT, (char *)&on);
  1592. X+           /* If we didn't do this, telnetd would become very */
  1593. X+           /* confused, because it's expecting packet-mode stuff. */
  1594. X+ 
  1595. X+           (void) fcntl(fdpass[0],F_SETFL,FNDELAY); /* XXX */
  1596. X+           (void) ioctl(fdsty,TIOCGPGRP,&pgrp);
  1597. X+           (void) setpgrp(0,pgrp);
  1598. X+ 
  1599. X+           /* XXX: If this messes up Linemode, TOUGH LUCK! */
  1600. X+               init_termbuf(); /* XXX */
  1601. X+ #ifdef LINEMODE
  1602. X+               localstat(); /* XXX */
  1603. X+ #endif
  1604. X+ 
  1605. X+           FD_ZERO(&xbits);
  1606. X+           FD_ZERO(&ibits); /* XXX */
  1607. X+           FD_ZERO(&obits);
  1608. X+ 
  1609. X+           /* XXX: anything else to do? */
  1610. X+          }
  1611. X+ #endif USEPTY
  1612. X+ 
  1613. X          /*
  1614. X           * Any urgent data?
  1615. X           */
  1616. X***************
  1617. X*** 881,888 ****
  1618. X--- 989,1004 ----
  1619. X              if (pcc < 0 && errno == EWOULDBLOCK)
  1620. X                  pcc = 0;
  1621. X              else {
  1622. X+ #ifndef USEPTY
  1623. X                  if (pcc <= 0)
  1624. X                      break;
  1625. X+ #else USEPTY
  1626. X+                 if (pcc <= 0)
  1627. X+                  {
  1628. X+                   pcc = 0;
  1629. X+                   goto wtfiseofpty;
  1630. X+                  }
  1631. X+ #endif USEPTY
  1632. X  #if    !defined(CRAY2) || !defined(UNICOS5)
  1633. X  #ifdef    LINEMODE
  1634. X                  /*
  1635. X***************
  1636. X*** 932,937 ****
  1637. X--- 1048,1056 ----
  1638. X                      ptyip = ptyibuf;
  1639. X  #endif    /* defined(CRAY2) && defined(UNICOS5) */
  1640. X              }
  1641. X+ #ifdef USEPTY
  1642. X+  wtfiseofpty: ;
  1643. X+ #endif USEPTY
  1644. X          }
  1645. X  
  1646. X          while (pcc > 0) {
  1647. END_OF_FILE
  1648.   if test 13647 -ne `wc -c <'patch/telnetd.90.06.28.patch'`; then
  1649.     echo shar: \"'patch/telnetd.90.06.28.patch'\" unpacked with wrong size!
  1650.   fi
  1651.   # end of 'patch/telnetd.90.06.28.patch'
  1652. fi
  1653. if test ! -d 'util' ; then
  1654.     echo shar: Creating directory \"'util'\"
  1655.     mkdir 'util'
  1656. fi
  1657. echo shar: End of archive 1 \(of 6\).
  1658. cp /dev/null ark1isdone
  1659. MISSING=""
  1660. for I in 1 2 3 4 5 6 ; do
  1661.     if test ! -f ark${I}isdone ; then
  1662.     MISSING="${MISSING} ${I}"
  1663.     fi
  1664. done
  1665. if test "${MISSING}" = "" ; then
  1666.     echo You have unpacked all 6 archives.
  1667.     rm -f ark[1-9]isdone
  1668. else
  1669.     echo You still must unpack the following archives:
  1670.     echo "        " ${MISSING}
  1671. fi
  1672. exit 0
  1673. exit 0 # Just in case...
  1674.